<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>人脸信息采集</title>
     <script src="js/faceUtil.js"></script>
     <script src="js/jquery.js"></script>
     <script src="js/vue.min.js"></script>
     <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            margin: 0;
            padding: 0;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        #myApp {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            padding: 40px;
            text-align: center;
            max-width: 550px;
            width: 90%;
            backdrop-filter: blur(10px);
        }
        
        h1 {
            color: #333;
            margin-bottom: 30px;
            font-weight: 600;
            font-size: 28px;
            letter-spacing: 1px;
        }
        
        #video {
            border: 4px solid #e0e0e0;
            border-radius: 15px;
            overflow: hidden;
            margin: 0 auto 25px;
            width: 400px;
            height: 450px; /* 进一步增加高度以显示更多区域 */
            background-color: #f8f9fa;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }
        
        .form-group {
            margin-bottom: 20px;
            text-align: left;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-weight: 500;
        }
        
        input {
            width: 100%;
            padding: 14px;
            border: 2px solid #e1e5e9;
            border-radius: 10px;
            font-size: 16px;
            transition: border-color 0.3s ease;
            box-sizing: border-box;
        }
        
        input:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }
        
        button {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            padding: 16px 40px;
            font-size: 18px;
            border-radius: 50px;
            cursor: pointer;
            margin-top: 20px;
            transition: all 0.3s ease;
            font-weight: 600;
            letter-spacing: 1px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }
        
        button:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
        }
        
        button:active {
            transform: translateY(1px);
        }
    </style>
</head>
<body>
    <div id="myApp">
        <h1>人脸信息采集</h1>
        <div id="video"></div>
        <div class="form-group">
            <label>姓名：</label>
            <input type="text" v-model="name" placeholder="请输入姓名"/>
        </div>
        <div class="form-group">
            <label>年龄：</label>
            <input type="text" v-model="age" placeholder="请输入年龄"/>
        </div>
        <div class="form-group">
            <label>电话：</label>
            <input type="text" v-model="phone" placeholder="请输入电话号码"/>
        </div>
        <button type="submit" @click="faceCollect">提交</button>
    </div>
</body>
<script>
    new Vue({
        el: '#myApp',
        data:{
            name: '',
            age:'',
            phone:''
        },
        methods:{
            faceCollect(){
                console.log("进入faceCollect函数")
                const code = faceUtile.getDecode();
                //faceUtile.collectFace(this.name, this.age, this.phone)
                const params = {
                    name: this.name,
                    age: this.age,
                    phone: this.phone,
                    image: code
                }
                //发送ajax请求
                $.ajax({
                    url: '/face_collect/',
                    type: 'post',
                    data: JSON.stringify(params),
                    success: function (res) {
                        if (res.code == 200) {
                            alert(res.msg);
                            console.log("跳转页面")
                            window.location.href = './predict.html';
                        }
                        else {
                            alert(res.msg);
                        }
                    }
                })
            }
        }

    })



    $(function () {
        //指定摄像头打开位置
        faceUtile.openVideo("video")
        faceUtile.width=400
        faceUtile.height=450  /* 调整摄像头高度以匹配新的显示区域 */
    })
</script>
</html>